#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int main() {
    int T;
    cin>>T;
    LL n, a;
    while (T--) {
        cin>>n>>a;
        if (n>2 || n==0) {
            printf("-1 -1\n");
        }
        else if(n==1) {
            printf("%lld %lld\n", 1, a+1);
        }
        else {
            LL b, c;
            if (a&1) {
                LL t=(a-1)/2;
                b = 2*t*t+2*t;
                c = b+1;
            }
            else {
                LL t=a/2;
                b=t*t-1;
                c=b+2;
            }
            printf("%lld %lld\n", b, c);
        }
    }
    return 0;
}
